﻿/*
 * 04/09/2010 - 1.0.0.1 - Eber Irigoyen
 * - Added support for context connection, execution wrapper should not open or close this connection
 *  - WithLiveConnection, takes a SqlConnection instance, which should be already open and ready to be used by SqlCommands
 */
using System;
using System.Data;
using System.Data.SqlClient;

namespace AbstractSql {
    public class AbsDBCommand {
        static IAbsDBCommandExecution GetCommand(CommandType commandType, string commandText) {
            AbsDBCommandExecution ce = new AbsDBCommandExecution();
            ce.CommandType = commandType;
            ce.CommandText = commandText;
            return ce;
        }
        public static IAbsDBCommandExecution StoredProc(string storedProcName) {
            return GetCommand(CommandType.StoredProcedure, storedProcName);
        }
        public static IAbsDBCommandExecution SqlCommand(string query) {
            return GetCommand(CommandType.Text, query);
        }
        public static IAbsDBCommand WithLiveConnection(SqlConnection connection) {
            return new _AbsDBCommand(connection);
        }
        internal static IAbsDBCommand WithConnection(string connectionName) {
            return new _AbsDBCommand(connectionName);
        }
    }
}